Commerce is computed base by base between factions with Treaties and Pacts, as follows:
(1) First, all bases for each faction are ranked from top to bottom by Energy output.
(2) Bases are paired off from top to bottom. If one faction has extra bases, these are ignored.
(3) For each pair of bases, sum the combined economic output and divide by 8, rounding up.
(4) Double this value if a Global Trade Pact is in effect.
(5) Now, for each individual base, the commerce formula is as follows:
(6) CommerceTech is the total # of economic technologies discovered, plus faction & social bonuses.
(7) TotalCommerceTech is the total # of economic technologies in the game.
(8) Now, using the value from step 5, divide by 2 if no Pact (e.g. only a Treaty)
(9) Add +1 if you are Planetary Governor.
(10) Reduce to zero if sanctions are in effect against either faction.